var Light = (function () {
    var _buttonWasPressed = function (that) {
        if (that.state === 'off') {
            alert('开灯');
            that.state = 'on';
        } else {
            alert('关灯');
            that.state = 'off';
        }
    }, lightFun = function () {
        this.state = 'off';
        this.button = null;
    };
    lightFun.prototype.init = function () {
        var button = document.createElement('button');
        button.innerHTML = '开关';
        this.button = document.body.appendChild(button);
        this.initEvents(this);
    };
    lightFun.prototype.initEvents = function () {
        var self = this;
        this.button.addEventListener('click', function () {
            _buttonWasPressed(self);
        });
    };
    return lightFun;
})();
$(function () {
    new Light().init();
});